package algorithm;

/**
 * @author 江岸
 * @version V1.0
 * @ClassName: demo
 * @description: 打印自身的程序
 * @date 2021/4/1513:14
 * @since V1.0
 */
public class Quine {
    public static void main(String[] args) {
        char q = 34;      // Quotation mark character
        String[] l = {    // Array of source code
                "public class Quine",
                "{",
                "  public static void main( String[] args )",
                "  {",
                "    char q = 34;      // Quotation mark character",
                "    String[] l = {    // Array of source code",
                "    ",
                "    };",
                "    for( int i = 0; i < 6; i++ )           // Print opening code",
                "        System.out.println( l[i] );",
                "    for( int i = 0; i < l.length; i++ )    // Print string array",
                "        System.out.println( l[6] + q + l[i] + q + ',' );",
                "    for( int i = 7; i < l.length; i++ )    // Print this code",
                "        System.out.println( l[i] );",
                "  }",
                "}",
        };
        for (int i = 0; i < 6; i++)           // Print opening code
            System.out.println(l[i]);
        for (int i = 0; i < l.length; i++)    // Print string array
            System.out.println(l[6] + q + l[i] + q + ',');
        for (int i = 7; i < l.length; i++)    // Print this code
            System.out.println(l[i]);
    }

//    public static void main(String[] args) {
//        String s = "public class Quine {%n    public static void main(String[] args) {%n        String s = %c%s%c;%n        System.out.printf(s, 34, s, 34);%n    }%n}";
//        System.out.printf(s, 34, s, 34);
//
//    }
}